﻿using Engine.UI;
using UnityEngine;

public class Driver : MonoBehaviour
{
    // Use this for initialization
    void Awake()
    {
        //跳转场景不销毁
        DontDestroyOnLoad(gameObject);
        //后台运行
        Application.runInBackground = true;
        //限制帧率30
        Application.targetFrameRate = 30;
        Screen.sleepTimeout = SleepTimeout.NeverSleep;

        Log.Init(true, true, Application.persistentDataPath);

        PathManager pathMgr = gameObject.AddComponent<PathManager>();
        pathMgr.Init();

        gameObject.AddComponent<MsgManager>();
        gameObject.AddComponent<NetManager>();

        ResManager resMgr = gameObject.AddComponent<ResManager>();
        resMgr.Init(OnResComplete);
    }

    void OnResComplete()
    {
        CheckUpdate();
    }

    /// <summary>
    /// 检查更新
    /// </summary>
    private void CheckUpdate()
    {
        UIManager.Instance.Init();
        UIManager.Instance.Show<UpdateView>();
    }
}